import { defineStore } from 'pinia'
import { IFileInfo } from '@/types/file'
import { getFolderInfoApi } from '@/apis/file'

export const useFileStore = defineStore('file', {
  state: () => ({
    fileInfoList: [] as IFileInfo[],
    previewFileTypeList: ['txt', 'sh', 'log'],
    currentFolder: '/root/service/logs',
    pathHistory: ['/root/service/logs']
  }),
  actions: {
    async queryFileInfoList() {
      this.fileInfoList = await getFolderInfoApi(this.currentFolder)
    }
  }
})
